class Watcher {
    constructor(vm, key, cb) {
        this.vm = vm
        this.keys =  key.split('.')
        this.cb = cb
        Dep.target = this
        
        // 触发get方法，条用dep.addSub
        this.value = this.vm
        this.keys.forEach(key => {
            this.value = this.value[key]
        })
        // this.value = vm[key]
        Dep.target = null
    }
    update() {
        let newValue = this.vm
        
        this.keys.forEach(key => {
            newValue = newValue[key]
        })
        // let newVal = this.vm[this.key]
        // if (this.value === newVal) {
        //     return
        // }
       
        console.log('update')
        this.cb(newValue)
    }
}